<%--
  Created by IntelliJ IDEA.
  User: 喝假酒的ywj
  Date: 2020/3/6
  Time: 20:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>i movie</title>
    <script src="${pageContext.request.contextPath}/js/jquery-3.4.1.min.js"></script>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/search.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css" />
    <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/jquery-url.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap-paginator.js"></script>
    <style>
        a,a:hover{
            text-decoration: none;
            color: #333;
        }
    </style>
    <script>
        $(function () {
            let kw = url('?kw');
            $('#kw').val(kw);
            if((${data.total})==0){
                $('#pagination').hide()
            }else{
                $('#pagination').bootstrapPaginator({
                    //主版本号
                    bootstrapMajorVersion: 3,
                    //当前页
                    currentPage: ${data.pageNum},
                    //总页数
                    totalPages: ${data.pages},
                    //请求url
                    pageUrl: function (type, page, current) {
                        return '${pageContext.request.contextPath}/front/movie/search?kw='+kw+'&pageNum='+page;
                    },
                    //显示分页条信息
                    itemTexts: function (type, page, current) {
                        switch (type) {
                            case "first":
                                return "首页";
                            case "prev":
                                return "上一页";
                            case "next":
                                return "下一页";
                            case "last":
                                return "尾页";
                            case "page":
                                return page;
                        }
                    },
                });
            }
           $('#searchBtn').click(function () {
               let kw1 = $('#kw').val()
               window.location.href='${pageContext.request.contextPath}/front/movie/search?kw='+kw1;
           })
        })
    </script>
</head>
<body>
<%@ include file="header.jsp"%>
<div class="search-container">
    <div class="search-box">
        <form class="search-form">
            <input class="kw" type="text" name="kw" maxlength="32" id="kw" style="outline: none">
            <button class="submit" type="button" id="searchBtn"></button>
        </form>
    </div>
    <div class="search-result-box">
        <dl class="movie-list">
            <c:forEach items="${data.list}" var="item">
            <dd>
                <div class="movie-item">
                    <a href="${pageContext.request.contextPath}/front/movie/movieDetail?id=${item.id}">
                        <div class="movie-poster">
                            <img alt="${item.name}海报" src="${item.cover}">
                        </div>
                    </a>
                    <div class="movie-ver"></div>
                </div>
                <div class="channel-detail movie-item-title" title="${item.name}">
                    <a href="${pageContext.request.contextPath}/front/movie/movieDetail?id=${item.id}">${item.name}</a>
                </div>
                <div class="movie-item-subtitle">${item.ename}</div>
                <div class="absolute-info">
                    <div class="channel-detail channel-detail-orange">
                        <i class="integer">${item.score}</i>
                    </div>
                    <div class="movie-item-cat">${item.type}</div>
                    <div class="movie-item-pub">${item.time}上映</div>
                </div>
            </dd>
            </c:forEach>
        </dl>
    </div>
    <nav style="text-align: center">
        <ul class="detail-pager" id="pagination" >页面</ul>
    </nav>
</div>
<%@ include file="footer.jsp"%>
</body>
</html>
